package com.jumi.microservice.common;

import com.jumi.microservice.common.base.dto.ResponseResult;
import com.jumi.microservice.material.service.JmWarehouseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author ssk
 * @create 2020/8/31 14:22
 **/
@RestController
@RequestMapping("/area")
@Api(tags = {"【基础资料】区域查询接口"})
public class AreaController{

    @Resource
    private JmWarehouseService jmWarehouseService;

    @GetMapping("/findArea")
    @ApiOperation(value = "根据层级/父ID查询地区信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deep", value = "层级", paramType = "Integer"),
            @ApiImplicitParam(name = "parentId", value = "父ID", paramType = "Long")
    })
    public ResponseResult findArea(Integer deep, Long parentId) {
        parentId = parentId == null ? 0L : parentId;
        deep = deep == null ? 1 : deep;
        List<Map<String, Object>> list = jmWarehouseService.findArea(deep, parentId);
        return ResponseResult.success(list);
    }
}
